package com.example.yamba;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.TextView;
import android.util.Log;

import com.sina.weibo.sdk.openapi.models.Status;

/**
 * Created by jagery on 8/25/15.
 */
public class TimelineActivity extends Activity{
    private static final String TAG = TimelineActivity.class.getSimpleName();
    TextView timelineText ;
    private StatusData statusData ;
    protected void onCreate(Bundle bundle){
       super.onCreate(bundle);
        setContentView(R.layout.timeline);
        timelineText = (TextView)findViewById(R.id.timelineText);
        statusData = ((YambaApplication)getApplication()).getStatusData();
        Log.i(TAG,"onCreated");
    }
    protected void onResume(){
        super.onResume();
        Cursor cursor = statusData.getStatusUpdates();
        String output ,user,statusStr ;
        Status status;
        while(cursor.moveToNext()){
            user = cursor.getString(cursor.getColumnIndex(StatusData.C_USER));
            statusStr = cursor.getString(cursor.getColumnIndex(StatusData.C_STATUS));
            status = Status.parse(statusStr);
            output = String.format("%s : %s\n\n",user,status.text);
            timelineText.append(output);
        }
    }
}
